package com.transaction.simulate.controller;

import com.transaction.common.base.BaseController;
import com.transaction.common.base.PageInfo;
import com.transaction.common.util.ParamsUtil;
import com.transaction.simulate.model.dto.FundRate;
import com.transaction.simulate.service.FundRateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@RestController
@RequestMapping("/fundRate")
public class FundRateController extends BaseController {

    @Autowired
    private FundRateService fundRateService;

    /**
     * 查询费率
     * @param request
     * @return
     */
    @GetMapping("/getFundRateList")
    public Object getFundRateList(HttpServletRequest request){
        PageInfo pageInfo = ParamsUtil.getPageInfo(request);
        FundRate fundRate = ParamsUtil.getBeanParam(new FundRate(),request);

        List<FundRate> dictList = fundRateService.getFundRateList(fundRate,pageInfo);
        pageInfo.setPageResult(dictList);
        return pageInfo;
    }

    /**
     * 删除费率
     * @param fundRate
     * @return
     */
    @PostMapping("/deleteFundRate")
    public Object deleteFundRate(@RequestBody FundRate fundRate){
        fundRateService.deleteFundRate(fundRate);
        return retResultVo();
    }

    /**
     * 新增费率
     * @param fundRate
     * @return
     */
    @PostMapping("/addFundRate")
    public Object addFundRate(@RequestBody FundRate fundRate){
        fundRateService.addFundRate(fundRate);
        return retResultVo();
    }

}
